package com.baizan.daka.mvp.model

import com.baizan.daka.mvp.model.bean.TaskInfoBean
import com.baizan.daka.net.BasePageResponse
import com.baizan.daka.net.bean.*
import com.baizan.daka.util.SchedulerUtils
import com.hazz.kotlinmvp.net.BaseResponse
import com.hazz.kotlinmvp.net.RetrofitManager
import io.reactivex.Observable

class TaskModel {

    fun upOrDown( enabledFlag: Int,  id: String,videoUrl:String?):Observable<BaseResponse<Any>>{
        return RetrofitManager.service.upOrDown(UpOrDownBean(enabledFlag, id,videoUrl))
            .compose(SchedulerUtils.ioToMain())
    }


    fun list(CurrentPage: Int,level: Int? = null ,taskClass:Int? = null): Observable<BaseResponse<BasePageResponse<TaskInfoBean>>> {
        val taskRequest = BasePageParam<TaskParamBean>(CurrentPage,  TaskParamBean(level,taskClass))
        return RetrofitManager.service.getTaskList(
            taskRequest
        ).compose(SchedulerUtils.ioToMain())
    }

    fun receivedTask(taskId: Long): Observable<BaseResponse<Any>> {
        return RetrofitManager.service.receivedTask(
            TaskIdBean(taskId)
        ).compose(SchedulerUtils.ioToMain())
    }

    fun submitTask(
        taskId: String,
        remark: String,
        imageUrl: List<String>
    ): Observable<BaseResponse<String>> {
        return RetrofitManager.service.submitTask(
            TaskSubmitBean(taskId, remark, imageUrl)
        ).compose(SchedulerUtils.ioToMain())
    }

    fun publishTask(publishBean: PublishBean):Observable<BaseResponse<String>> {
        return RetrofitManager.service.publishTask(publishBean
        ).compose(SchedulerUtils.ioToMain())
    }

}